﻿using UnityEngine;
using System.Collections;
using spaar.ModLoader;
using ShooterGameMOD_Besiege.Player;

namespace ShooterGameMOD_Besiege
{

    /// <summary>
    /// 武器生成脚本
    /// </summary>
    public class WeaponsSpawnerScript : MonoBehaviour
    {

        bool spawned = false;

        public GameObject WeaponObjects;

        GameObject w;

        // Use this for initialization
        void Start()
        {
            WeaponObjects = new GameObject("WeaponObjects");
            WeaponObjects.transform.SetParent(transform);
        }

        // Update is called once per frame
        void Update()
        {
            if (ShooterGameMod.isBuilding())
            {
                if (PlayerScript.playerCreated && !spawned )
                {
                    spawned = true;

                    w = Machine.Active().AddBlock(new Vector3(6, 3, 6), transform.rotation, (int)BlockType.Crossbow).gameObject;

                    //w = (GameObject)Instantiate(PrefabMaster.BlockPrefabs[(int)BlockType.Crossbow].gameObject, new Vector3(6, 3, 6), transform.rotation,Machine.Active().BuildingMachine);
                    //w.GetComponent<Rigidbody>().isKinematic = false;
                    //w.GetComponent<CrossBowBlock>().SimBlock = Machine.Active().BuildingBlocks.Find(match => match.);

                }
            }
        }
    }
}

